package com.yfp.machine.service.impl;

import com.yfp.machine.domain.Combo;
import com.yfp.machine.mapper.ComboMapper;
import com.yfp.machine.service.ComboService;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;

import java.util.List;

/**
 * 套餐表(Combo)表服务实现类
 *
 *
 * @since 2023-12-24 14:36:34
 */
@Service("comboService")
public class ComboServiceImpl implements ComboService {
    @Resource
    private ComboMapper comboMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param comboId 主键
     * @return 实例对象
     */
    @Override
    public Combo queryById(String comboId) {
        return this.comboMapper.queryById(comboId);
    }

    /**
     * 分页查询
     *
     * @param combo 筛选条件
     * @return 查询结果
     */
    @Override
    public List<Combo> queryByPage(Combo combo) {
        return this.comboMapper.queryAllByLimit(combo);
    }

    /**
     * 新增数据
     *
     * @param combo 实例对象
     * @return 实例对象
     */
    @Override
    public Combo insert(Combo combo) {
        this.comboMapper.insert(combo);
        return combo;
    }

    /**
     * 修改数据
     *
     * @param combo 实例对象
     * @return 实例对象
     */
    @Override
    public Combo update(Combo combo) {
        this.comboMapper.update(combo);
        return this.queryById(combo.getComboId());
    }

    /**
     * 按组合id查询后台img
     *
     * @param comboId 组合id
     * @return {@link String}
     */
    @Override
    public String queryBackgroundImgByComboId(String comboId) {
        return this.comboMapper.queryBackgroundImgByComboId(comboId);
    }
}
